The present invention relates to the field of computer graphics. Many computer graphic images are created by mathematically modeling the interaction of light with a three dimensional scene from a given viewpoint. This process, called rendering, generates a two-dimensional image of the scene from the given viewpoint, and is analogous to taking a photograph of a real-world scene.
As the demand for computer graphics, and in particular for real-time computer graphics, has increased, computer systems with graphics processing subsystems adapted to accelerate the rendering process have become widespread. In these computer systems, the rendering process is divided between a computer's general purpose central processing unit (CPU) and the graphics processing subsystem. Typically, the CPU performs high level operations, such as determining the position, motion, and collision of objects in a given scene. From these high level operations, the CPU generates a set of rendering instructions and data defining the desired rendered image or images. For example, rendering instructions and data can define scene geometry, lighting, shading, texturing, motion, and/or camera parameters for a scene. The graphics processing subsystem creates one or more rendered images from the set of rendering instructions and data.
To maximize rendering performance, it is generally desirable for the CPU and graphics processing subsystem to execute the minimum number of operations necessary to render the images. Geometry culling optimizes the number of rendering operations by bypassing rendering operations for geometry and objects that are not visible in a scene. Typically, geometry culling performs one or more visibility tests on the geometry or object to be rendered. If the visibility test fails, the geometry or object will not be visible in the final rendered image; thus, rendering of the object can be bypassed. Conversely, if the geometry or object passes the visibility test, the object or geometry must be rendered (though the object may turn out to be hidden in the final rendered image). A number of different visibility tests of varying complexity and accuracy exist.
Conditionally rendering objects and geometry in a graphics processing subsystem presents a number of difficulties. First, the visibility of one object is often dependent upon other objects within a scene. Previously, it has been difficult for a graphics processing subsystem to use the results from rendering one object to conditionally render a subsequent object. Second, it is difficult for the CPU to assist the graphics processing subsystem in conditionally rendering objects. Typically, the CPU and graphics processing subsystem operate asynchronously to maximize performance. Once the scene description (a collection of rendering commands) is sent to the graphics processing subsystem, it is very hard for the CPU, in response to a visibility test, to intervene and cancel some of the rendering commands.
Third, completely CPU-based culling solutions are difficult and time-consuming to implement. For example, applications can use vertex shader programs to modify geometry positions. A CPU-based culling solution would be required to fully execute a vertex shader in order to determine whether or not a block of geometry can be culled. This would effectively eliminate any potential benefits from graphics processing subsystem accelerated geometry processing as the graphics processing subsystem would effectively be bottlenecked by the CPU's ability to execute vertex programs on geometric data. In addition, computation of vertex programs on the CPU steals cycles that could be used for application computations such as AI and physics calculations.
It is therefore desirable for a graphics processing subsystem to perform conditional rendering efficiently without assistance from the CPU. It is further desirable to seamlessly integrate the conditional rendering capabilities of the GPU with the CPU or other graphics processing subsystems, such as a second GPU or a graphics coprocessor, to perform more complicated visibility determinations.